package src.算法.冒泡排序;

public class 数组简单冒泡排序 {
    public static void sort(int [] arr){
        for (int i = arr.length-1; i >0 ; i--) {
            for (int j = 0; j < i; j++) {
                if(arr[j]>arr[j+1]){
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                }
            }
        }
    }
    public static void main(String[] args) {
        int[] a = {3,1,4,2,6,5,8,7,9};
        sort(a);

        for (int i : a) {
            System.out.print(i+" ");
        }
    }
}
